package com.cyl.manager.oms.controller;

import com.cyl.manager.oms.domain.entity.BannerInfo;
import com.cyl.manager.oms.domain.entity.Order;
import com.cyl.manager.oms.domain.form.ManagerOrderQueryForm;
import com.cyl.manager.oms.domain.vo.BannerInfoVO;
import com.cyl.manager.oms.domain.vo.ManagerOrderVO;
import com.cyl.manager.oms.service.BannerService;
import com.cyl.manager.oms.service.OrderService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单表Controller
 *
 * @author zcc
 * @date 2022-12-01
 */
@Api(description ="banner 管理接口")
@RestController
@RequestMapping("/oms/banner")
@Slf4j
public class BannerController extends BaseController {
    @Autowired
    private BannerService service;

    @ApiOperation("查询banner")
    @PreAuthorize("@ss.hasPermi('oms:banner:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<BannerInfoVO>> list(@RequestBody ManagerOrderQueryForm query, Pageable page) {
        return ResponseEntity.ok(service.selectList(query, page));
    }

    @ApiOperation("新增banner")
    @PreAuthorize("@ss.hasPermi('oms:banner:save')")
    @Log(title = "新增banner", businessType = BusinessType.INSERT)
    @PostMapping("save")
    public ResponseEntity<Integer> save(@RequestBody BannerInfo bannerInfo) {
        return ResponseEntity.ok(service.save(bannerInfo));
    }

    @ApiOperation("删除订单表")
    @PreAuthorize("@ss.hasPermi('oms:banner:remove')")
    @Log(title = "订单表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public ResponseEntity<Integer> remove(@PathVariable Long id) {
        return ResponseEntity.ok(service.deleteById(id));
    }

}
